package com.fhz.a2102shopjava.di;

import android.content.Context;
import android.os.UserManager;

import com.fhz.a2102shopjava.dao.AppDatabase;
import com.fhz.a2102shopjava.dao.UserDao;

import javax.inject.Inject;
import javax.inject.Singleton;

import dagger.Module;
import dagger.Provides;
import dagger.hilt.InstallIn;
import dagger.hilt.android.components.ActivityComponent;
import dagger.hilt.android.qualifiers.ApplicationContext;
import dagger.hilt.components.SingletonComponent;

/**
 * 时间:2023/8/15
 *
 * @author Mr.Feng
 * 简述: room 数据库注入
 *
 */
@Module
@InstallIn(SingletonComponent.class)
public class DataBaseModule {

    @Singleton
    @Provides
    public AppDatabase getMyDatabase(@ApplicationContext Context context){
        return AppDatabase.getInstance(context);
    }

    @Provides
    @Singleton
    public UserDao getUserDao(AppDatabase myDatabase){
        return myDatabase.userDao();
    }

//    @Singleton
//    @Provides
//    public UserManager getACache(@ApplicationContext Context context){
//        return UserManager.getInstance(context);
//    }
}   
